﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;

namespace Netwerk_Sniffer
{
    public partial class Form1 : Form
    {

        
        byte[] inn = new byte[4] { 1, 0, 0, 0 };
        byte[] outt = new byte[4];
        byte[] byteData = new byte[4096];

        public Form1()
        {
            InitializeComponent();
            Socket sock;
            sock = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.IP);
            sock.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.0.100"), 0));
            sock.SetSocketOption(SocketOptionLevel.IP,  
                             SocketOptionName.HeaderIncluded,
                             true);
            sock.IOControl(IOControlCode.ReceiveAll,  
                     inn, outt);
            
            sock.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,
                        new AsyncCallback(OnReceive), null);
            
        }
        private void OnReceive(IAsyncResult ar) {
            
        }
        private void button1_Click(object sender, EventArgs e)
        {
            lb_ip.Text = inn[3].ToString();
           

        }

    }
}
